*************************************************************************
*																		*
*	Campaign Panel Book Do-File Chapter 2 - Tables 8, 9, 11, 12			*
*																		*
**************************************************************************


***Table 8

foreach year in a b {
	gen `year'_duell_merk6_media = `year'_kp6_1880
	recode `year'_duell_merk6_media (99 100 = .) 
	replace `year'_duell_merk6_media = (`year'_duell_merk6_media-5)/(-4)
	gen `year'_duell_stein6_media = `year'_kp6_1890
	recode `year'_duell_stein6_media (99 100 = .) 	
	replace `year'_duell_stein6_media = (`year'_duell_stein6_media-5)/(-4)
	gen `year'_duell_merk6_peer = `year'_kp6_1910
	recode `year'_duell_merk6_peer (99 100 = .)
	replace `year'_duell_merk6_peer = (`year'_duell_merk6_peer-5)/(-4)
	gen `year'_duell_stein6_peer = `year'_kp6_1920
	recode `year'_duell_stein6_peer (99 100 = .) 
	replace `year'_duell_stein6_peer = (`year'_duell_stein6_peer-5)/(-4)
}


foreach year in a b {
	foreach var in `year'_duell_merk6_media `year'_duell_stein6_media `year'_duell_merk6_peer `year'_duell_stein6_peer {
		table `var' [aw=`year'_weight]
		mean `var' [aw=`year'_weight]
		bysort `year'_pidfull1: sum `var' [aw=`year'_weight]
}
}



***Table 9



gen b_vaa_result = b_kp5_3510 
	recode b_vaa_result (.a .c .e .g = .) (.b=998)
	replace b_vaa_result = b_kp6_3510 if b_vaa_result==.
	recode b_vaa_result (.a .c .e .g = .) (.b=998)
	replace b_vaa_result = b_kp7_3510 if b_vaa_result==.
	recode b_vaa_result (.a .c .e .g = .) (.b=998)

tab b_vaa_result [aw=b_weight]
bysort b_pidfull1: tab b_vaa_result [aw=b_weight]


***Table 11

foreach year in a b {
	foreach var in `year'_duell_merk6 `year'_duell_stein6 {
		sum `var' [aw=`year'_weight]
		bysort `year'_pidfull1: sum `var' [aw=`year'_weight]
}
}

foreach year in b {
	foreach var in `year'_arena_merk6_a `year'_arena_stein6_a {
		sum `var' [aw=`year'_weight]
		bysort `year'_pidfull1: sum `var' [aw=`year'_weight]
}
}


***Table 12

gen b_fdp_winner_bav6 = b_kp6_3220d
replace b_fdp_winner_bav6 = (b_fdp_winner_bav6-1)/(4)

foreach year in b {
	foreach var in  `year'_mittelfinger7 `year'_paed7 `year'_drohne_handling3 `year'_fdp_winner_bav6 {
		sum `var' [aw=`year'_weight]
		bysort `year'_pidfull1: sum `var' [aw=`year'_weight]
}
}





save "${data}\data2009_2013 participants 7 waves.dta", replace
